/**
 * pharma-model - 9 janv. 2011 guillaume
 */
package org.bspv.pharma.model;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Version;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import org.bspv.pharma.common.constant.Constants;

/**
 * @author guillaume
 */
@Entity
@Table(name = "USER")
public class User implements Serializable {

    /**
     * serialVersionUID.
     */
    private static final long serialVersionUID = -6512972362475495828L;

    /**
     * Enumération correspondant aux grades des utilisateurs.
     *
     * @author guillaume
     */
    public enum RankEnum {
        /**
         * Moquette :-).
         */
        SAPEUR,
        /**
         * Grade de caporal.
         */
        CAPORAL,
        /**
         * Grade de caporal-chef.
         */
        CAPORALCHEF,
        /**
         * Grade de sergent.
         */
        SERGENT,
        /**
         * Grade de sergent-chef.
         */
        SERGENTCHEF,
        /**
         * Grade d'adjudant.
         */
        ADJUDANT,
        /**
         * Grade d'adjudant-chef.
         */
        ADJUDANTCHEF,
        /**
         * Grade de major.
         */
        MAJOR,
        /**
         * Grade de lieutenant.
         */
        LIEUTENANT,
        /**
         * Grade de capitaine.
         */
        CAPITAINE,
        /**
         * Grade de commandant.
         */
        COMMANDANT,
        /**
         * Grade de lieutenant-colonel.
         */
        LIEUTENANTCOLONEL,
        /**
         * Grade de colonel.
         */
        COLONEL
    }

    /**
     * Identifiant de l'utilisateur.
     */
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    /**
     * Login.
     */
    @NotNull
    @Size(max = Constants.CONSTRAINT_NAME_SIZE)
    private String username;
    /**
     * Mot de passe.
     */
    @NotNull
    @Size(max = Constants.CONSTRAINT_NAME_SIZE)
    private String password;
    /**
     * Prénom de l'utilisateur.
     */
    @Size(max = Constants.CONSTRAINT_NAME_SIZE)
    private String firstname;
    /**
     * Nom de l'utilisateur.
     */
    @Size(max = Constants.CONSTRAINT_NAME_SIZE)
    private String name;
    /**
     * Grade de l'utilisateur.
     */
    @Enumerated(EnumType.STRING)
    private RankEnum rank;
    /**
     * Adresse mail de l'utilisateur.
     */
    @Size(max = Constants.CONSTRAINT_EMAIL_SIZE)
    private String email;
    /**
     * Numéro de téléphone de l'utilisateur.
     */
    @Size(max = Constants.CONSTRAINT_PHONE_SIZE)
    private String phone;
    /**
     * Numéro de mobile.
     */
    @Size(max = Constants.CONSTRAINT_PHONE_SIZE)
    private String mobile;
    /**
     * Centre de secours.
     */
    @NotNull
    @ManyToOne
    private FireStation fireStation;
    /**
     * Indique si le compte est valide.
     */
    @NotNull
    private Boolean validAccount;
    /**
     * Numéro de version.
     */
    @Version
    private Integer version;

    /**
     * @return the id
     */
    public final Long getId() {
        return id;
    }

    /**
     * @param id
     *            the id to set
     */
    public final void setId(final Long id) {
        this.id = id;
    }

    /**
     * @return the username
     */
    public final String getUsername() {
        return username;
    }

    /**
     * @param username
     *            the username to set
     */
    public final void setUsername(final String username) {
        this.username = username;
    }

    /**
     * @return the password
     */
    public final String getPassword() {
        return password;
    }

    /**
     * @param password
     *            the password to set
     */
    public final void setPassword(final String password) {
        this.password = password;
    }

    /**
     * @return the firstname
     */
    public final String getFirstname() {
        return firstname;
    }

    /**
     * @param firstname
     *            the firstname to set
     */
    public final void setFirstname(final String firstname) {
        this.firstname = firstname;
    }

    /**
     * @return the name
     */
    public final String getName() {
        return name;
    }

    /**
     * @param name
     *            the name to set
     */
    public final void setName(final String name) {
        this.name = name;
    }

    /**
     * @return the rank
     */
    public final RankEnum getRank() {
        return rank;
    }

    /**
     * @param rank
     *            the rank to set
     */
    public final void setRank(final RankEnum rank) {
        this.rank = rank;
    }

    /**
     * @return the email
     */
    public final String getEmail() {
        return email;
    }

    /**
     * @param email
     *            the email to set
     */
    public final void setEmail(final String email) {
        this.email = email;
    }

    /**
     * @return the phone
     */
    public final String getPhone() {
        return phone;
    }

    /**
     * @param phone
     *            the phone to set
     */
    public final void setPhone(final String phone) {
        this.phone = phone;
    }

    /**
     * @return the mobile
     */
    public final String getMobile() {
        return mobile;
    }

    /**
     * @param mobile
     *            the mobile to set
     */
    public final void setMobile(final String mobile) {
        this.mobile = mobile;
    }

    /**
     * @return the fireStation
     */
    public final FireStation getFireStation() {
        return fireStation;
    }

    /**
     * @param fireStation
     *            the fireStation to set
     */
    public final void setFireStation(final FireStation fireStation) {
        this.fireStation = fireStation;
    }

    /**
     * @return the validAccount
     */
    public final Boolean getValidAccount() {
        return validAccount;
    }

    /**
     * @param validAccount
     *            the validAccount to set
     */
    public final void setValidAccount(final Boolean validAccount) {
        this.validAccount = validAccount;
    }

    /**
     * @return the version
     */
    public final Integer getVersion() {
        return version;
    }

    /**
     * @param version
     *            the version to set
     */
    public final void setVersion(final Integer version) {
        this.version = version;
    }

}
